import { createApp } from 'vue';
import App from './App.vue';

// 引入ant-design-vue
import Antd from "ant-design-vue";
import "ant-design-vue/dist/antd.css";

// 引入路由文件
import router from "@/router/index.js";

// 引入iconfont静态图标库
import "@/assets/iconfont/iconfont.css";
import "@/assets/iconfont/iconfont.js";

// 引入iconfont动态图标库
import {
	IconfontUrlCss,
	IconfontVersion,
	loadStyle
} from '@/assets/iconfont/config.js';
IconfontVersion.forEach((item)=>{
    loadStyle(IconfontUrlCss.replace("$key",item));
});

const app = createApp(App);

// 引入element-plus
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";

// 注册所有图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
};

// 引入qilin-element3x
import QilinElement from "qilin-element3x";
import "qilin-element3x/style.css";

// 引入并注册全局组件
import CodeMirror from "@/components/CodeMirror.vue";
import QilinCard from "@/components/QilinCard.vue";
import QilinCollapse from "@/components/QilinCollapse.vue";
import QilinExplain from "@/components/QilinExplain.vue";
// import QilinView from "@/global/components/QilinView/QilinView.vue";
// app.component("QilinView",QilinView);
app.component("CodeMirror",CodeMirror);
app.component("QilinCard",QilinCard);
app.component("QilinCollapse",QilinCollapse);
app.component("QilinExplain",QilinExplain);

// 引入并注册全局自定义指令
// import number from "@/global/directives/number/index.js";
// app.directive("number",number);

// 引入pinia模块
import store from "@/store/index.js";

// 引入打印插件
import print from "vue3-print-nb";

// 全局注册WebSocket服务
// import { webSocketService } from "@/utils/WebSocket.js";
// app.config.globalProperties.$websocket = webSocketService;
// const wsUrl = "ws://192.168.10.103:8081/ws/order?Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjoyNDIiLCJyblN0ciI6ImVsWTRYcjg5QjVjMzNEaGZoTFFIY0FaR1g1aVh4Rmo5IiwidXNlcklkIjoyNDJ9.TtGh4qD5TRpME4FqX0mPwZYJmc6M9umNac3SCv2BPgE";
// webSocketService.connect(wsUrl);
// app.provide("websocket",webSocketService);

// 解决 global is not defined 错误
window.global = window;

app.use(print).use(ElementPlus).use(QilinElement).use(store).use(Antd).use(router).mount('#app');
